import CryptoJS from "crypto-js/crypto-js"

export function encrypt(content, key){
    if (key.length > 16) {
        key = key.slice(0, 16);
    } else {
        let len = 16 - key.length;
        for (let i=0; i<len; i++) {
            key = key + "0"
        }
    }
    let sKey = CryptoJS.enc.Utf8.parse(key);
    let sContent = CryptoJS.enc.Utf8.parse(content);
    let encrypted = CryptoJS.AES.encrypt(sContent, sKey, {mode:CryptoJS.mode.ECB,padding: CryptoJS.pad.Pkcs7});
    return encrypted.toString();
}